package world;

import java.nio.IntBuffer;

import org.lwjgl.BufferUtils;

public class Crosshair {
	private IntBuffer verticesBuffer;
	private Vertex[] vertexes = new Vertex[6];

	public Crosshair() {
	}

	public void createVertexes(float x, float y, float w, float h) {
		// front
		int i = 0;
		float zPostion =-100.0f;
		x=0;
		y=0;
		w=4;
		h=3f;
				
		vertexes[i++] = new Vertex().setXYZ(x, y + h, zPostion).setRGB(1, 0, 0).setST(0, 0);
		vertexes[i++] = new Vertex().setXYZ(x + w, y + h, zPostion).setRGB(1, 1, 1).setST(1, 0);	
		vertexes[i++] = new Vertex().setXYZ(x + w, y, zPostion).setRGB(0, 0, 1).setST(1, 1);
		vertexes[i++] = new Vertex().setXYZ(x, y, zPostion).setRGB(0, 1, 0).setST(0, 1);
	}

	public void buildRenderData() {
		verticesBuffer = BufferUtils.createIntBuffer(4* Vertex.SIZE_ALL);
		for (int i = 0; i < 4; i++) {// 6 vertexes
			verticesBuffer.put(vertexes[i].getElements());
		}
		verticesBuffer.flip();
	}
	
	public IntBuffer getVerticesBuffer() {
		return verticesBuffer;
	}
}